Linear Search in PHP
The following function searches for an element $x from an array called $arr by going through each element of the array, one by one. If the element is found in the array, the function returns the index of the element, otherwise, it returns -1. Linear Search function using PHP <?php function search($arr, $x) { for($i... » read more